import React, {Component} from 'react';
import HelloWorld from "./HelloWorld";

class App extends Component {
    constructor() {
        super();
        this.state={
            flag:false
        }
    }
    flagChange(){
        this.setState({
            flag:true
        })
    }
    render() {
        const {flag} = this.state
        return (
            <div>
                <h1>哈哈哈</h1>
                <button onClick={e=>this.flagChange()}>切换</button>
                { flag &&  <HelloWorld></HelloWorld>}
            </div>
        );
    }
}

export default App;
